package com.jiang.daily.Q1760;

import java.util.Arrays;

/**
 * @author Jiang
 * @version 1.0
 * @date 2025/02/12 1:38
 */
class Solution {
    public int minimumSize(int[] nums, int maxOperations) {
        int l = 1, r = Arrays.stream(nums).max().getAsInt();
        int res = 0;
        while (l <= r) {
            long ops = 0;
            int mid = (l + r) / 2;
            for (int num: nums) {
                ops += (num - 1) / mid;
            }
            if (ops <= maxOperations) {
                res = mid;
                r = mid - 1;
            } else {
                l = mid + 1;
            }
        }
        return res;
    }
}
